package cn.dao.Impl;

import cn.base.Impl.IBaseDaoImpl;
import cn.dao.DepartmentDao;
import cn.domain.Department;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by jiaxiang Huang on 2017/3/9.
 */
@Repository
public class DepartmentDaoImpl extends IBaseDaoImpl<Department> implements DepartmentDao {

    @Override
    public List<Department> topList() {
        String hql="FROM Department where parentId is null";
        List<Department> list= this.session().createQuery(hql).list();
        return list;
    }

    @Override
    public List<Department> downList(Long id) {
        String hql="From Department where parent.id = ?";
        return session().createQuery(hql).setParameter(0,id).list();
    }

    @Override
    public List<Department> getByIds(Long id) {
        String hql="From Department where id != ?";
        return session().createQuery(hql).setParameter(0,id).list();
    }

}
